<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!-- Copyright 1997 The Open Group, All Rights Reserved -->
<title>time</title>
</head><body bgcolor=white>
<center>
<font size=2>
The Single UNIX &reg; Specification, Version 2<br>
Copyright &copy; 1997 The Open Group

</font></center><hr size=2 noshade>
<h4><a name = "tag_001_014_2277">&nbsp;</a>NAME</h4><blockquote>
time - time a simple command
</blockquote><h4><a name = "tag_001_014_2278">&nbsp;</a>SYNOPSIS</h4><blockquote>
<pre><code>

time <b>[</b>-p<b>] </b><i>utility </i><b>[</b><i>argument</i>...<b>]</b>
</code>
</pre>
</blockquote><h4><a name = "tag_001_014_2279">&nbsp;</a>DESCRIPTION</h4><blockquote>
The
<i>time</i>
utility invokes the utility named by the
<i>utility</i>
operand with arguments supplied as the
<i>argument</i>
operands and writes a message to standard error
that lists timing statistics for the utility.
The message includes the following information:
<ul>
<p>
<li>
The elapsed (real) time between invocation of
<i>utility</i>
and its termination.
<p>
<li>
The User CPU time, equivalent to the sum of the
<i>tms_utime</i>
and
<i>tms_cutime</i>
fields returned by the <b>XSH</b> specification
<i><a href="../xsh/times.html">times()</a></i>
function for the process in which
<i>utility</i>
is executed.
<p>
<li>
The System CPU time, equivalent to the sum of the
<i>tms_stime</i>
and
<i>tms_cstime</i>
fields returned by the
<i><a href="../xsh/times.html">times()</a></i>
function for the process in which
<i>utility</i>
is executed.
<p>
</ul>
<p>
The precision of the timing will be no less than the
granularity defined for the size of the clock tick
unit on the system, but the results will be
reported in terms of standard time units (for example,
0.02 seconds, 00:00:00.02, 1m33.75s, 365.21 seconds),
not numbers of clock ticks.
<p>
When
<i>time</i>
is used as part of a pipeline, the times reported are unspecified,
except when it is the sole command within a grouping command (see
<xref href=grpcmd><a href="chap2.html#tag_001_009_004">
Compound Commands
</a></xref>)
in that pipeline.
For example, the commands on the left are unspecified;
those on the right report on utilities
a
and
c,
respectively:
<pre>
<code>
time a | b | c    { time a } | b | c
a | b | time c    a | b | (time c)
</code>
</pre>
</blockquote><h4><a name = "tag_001_014_2280">&nbsp;</a>OPTIONS</h4><blockquote>
The
<i>time</i>
utility supports the <b>XBD</b> specification, <a href="../xbd/utilconv.html#usg"><b>Utility Syntax Guidelines</b>&nbsp;</a> .
<p>
The following option is supported:
<dl compact>

<dt><b>-p</b>
<dd>Write the timing output to standard error in the format shown in
the STDERR section.

</dl>
</blockquote><h4><a name = "tag_001_014_2281">&nbsp;</a>OPERANDS</h4><blockquote>
The following operands are supported:
<dl compact>

<dt><i>utility</i><dd>The name of a utility that is to be invoked.
If the
<i>utility</i>
operand names any of the special built-in utilities in
<xref href=sbi><a href="chap2.html#tag_001_014">
Special Built-in Utilities
</a></xref>,
the results are undefined.

<dt><i>argument</i><dd>
Any string to be supplied as an argument when invoking the
utility named by the
<i>utility</i>
operand.

</dl>
</blockquote><h4><a name = "tag_001_014_2282">&nbsp;</a>STDIN</h4><blockquote>
Not used.
</blockquote><h4><a name = "tag_001_014_2283">&nbsp;</a>INPUT FILES</h4><blockquote>
None.
</blockquote><h4><a name = "tag_001_014_2284">&nbsp;</a>ENVIRONMENT VARIABLES</h4><blockquote>
The following environment variables affect the execution of
<i>time</i>:
<dl compact>

<dt><i>LANG</i><dd>Provide a default value for the internationalisation variables
that are unset or null.
If
<i>LANG</i>
is unset or null, the corresponding value from the
implementation-dependent default locale will be used.
If any of the internationalisation variables contains an invalid setting, the
utility will behave as if none of the variables had been defined.

<dt><i>LC_ALL</i><dd>
If set to a non-empty string value,
override the values of all the other internationalisation variables.

<dt><i>LC_CTYPE</i><dd>
Determine the
locale for the interpretation of sequences of bytes of text data as
characters (for example, single- as opposed to multi-byte characters
in arguments).

<dt><i>LC_MESSAGES</i><dd>
Determine the locale that should be used to affect
the format and contents of diagnostic
and informative messages written to standard error.

<dt><i>LC_NUMERIC</i><dd>
Determine the locale for numeric formatting.

<dt><i>NLSPATH</i><dd>
Determine the location of message catalogues
for the processing of
<i>LC_MESSAGES .
</i>
<dt><i>PATH</i><dd>Determine the search path
that will be used to locate the utility to be invoked.
See
the <b>XBD</b> specification, <a href="../xbd/envvar.html"><b>Environment Variables</b>&nbsp;</a> .

</dl>
</blockquote><h4><a name = "tag_001_014_2285">&nbsp;</a>ASYNCHRONOUS EVENTS</h4><blockquote>
Default.
</blockquote><h4><a name = "tag_001_014_2286">&nbsp;</a>STDOUT</h4><blockquote>
Not used.
</blockquote><h4><a name = "tag_001_014_2287">&nbsp;</a>STDERR</h4><blockquote>
The standard error will be used to write
the timing statistics.
If
<b>-p</b>
is specified, the following format will be used
in the POSIX locale:
<p><code>
<tt>"real %f\nuser %f\nsys %f\n"</tt>, &lt;<i>real&nbsp;seconds</i>&gt;,
&lt;<i>user&nbsp;seconds</i>&gt;,
&lt;<i>system&nbsp;seconds</i>&gt;
</code>
<p>
where each floating-point number is expressed in seconds.
The precision used may be less than the default six digits of
<b>%f</b>,
but will be sufficiently precise to accommodate
the size of the clock tick on the system (for example,
if there were 60 clock ticks per second, at least two digits
follow the radix character).
The number of digits
following the radix character will be no less
than one, even if this always results in a trailing zero.
The implementation may append white space and additional
information following the format shown here.
</blockquote><h4><a name = "tag_001_014_2288">&nbsp;</a>OUTPUT FILES</h4><blockquote>
None.
</blockquote><h4><a name = "tag_001_014_2289">&nbsp;</a>EXTENDED DESCRIPTION</h4><blockquote>
None.
</blockquote><h4><a name = "tag_001_014_2290">&nbsp;</a>EXIT STATUS</h4><blockquote>
If the
<i>utility</i>
utility is invoked, the exit status of
<i>time</i>
will be the
exit status of
<i>utility;</i>
otherwise, the
<i>time</i>
utility will exit with one of the following values:
The following exit values are returned:
<dl compact>

<dt>1'<dd>An error occurred in the
<i>time</i>
utility.

<dt>126<dd>The utility specified by
<i>utility</i>
was found but could not be invoked.

<dt>127<dd>The utility specified by
<i>utility</i>
could not be found.

</dl>
</blockquote><h4><a name = "tag_001_014_2291">&nbsp;</a>CONSEQUENCES OF ERRORS</h4><blockquote>
Default.
</blockquote><h4><a name = "tag_001_014_2292">&nbsp;</a>APPLICATION USAGE</h4><blockquote>
The
<i><a href="command.html">command</a></i>,
<i><a href="env.html">env</a></i>,
<i><a href="nice.html">nice</a></i>,
<i><a href="nohup.html">nohup</a></i>,
<i>time</i>,
and
<i><a href="xargs.html">xargs</a></i>
utilities have been specified to use
exit code 127 if an error occurs so that
applications can distinguish
&quot;failure to find a utility&quot; from &quot;invoked utility exited
with an error indication.&quot;
The value 127 was chosen because it is not commonly used for other meanings;
most utilities use small values for &quot;normal error conditions&quot; and
the values above 128 can be confused with termination due to receipt of a
signal.
The value 126
was chosen in a similar manner to indicate that the utility
could be found, but not invoked.
Some scripts produce meaningful error messages
differentiating the 126 and 127 cases.
The distinction between exit codes 126 and 127 is based
on KornShell practice that uses 127 when all attempts to
<i>exec</i>
the utility fail with
[ENOENT],
and uses 126 when any attempt to
<i>exec</i>
the utility fails for any other reason.
</blockquote><h4><a name = "tag_001_014_2293">&nbsp;</a>EXAMPLES</h4><blockquote>
It is frequently desirable to apply
<i>time</i>
to pipelines or lists of commands.
This can be done by placing pipelines
and command lists in a single file; this file can then be
invoked as a utility, and the
<i>time</i>
applies to everything in the file.
<p>
Alternatively, the following command can be used to apply
<i>time</i>
to a complex command:
<pre>
<code>
time sh -c '<i>complex-command-line</i>'
</code>
</pre>
</blockquote><h4><a name = "tag_001_014_2294">&nbsp;</a>FUTURE DIRECTIONS</h4><blockquote>
None.
</blockquote><h4><a name = "tag_001_014_2295">&nbsp;</a>SEE ALSO</h4><blockquote>
<i><a href="sh.html">sh</a></i>
<i><a href="chap2.html#tag_001_014_013">times</a></i>
special built-in utility.
</blockquote><hr size=2 noshade>
<center><font size=2>
UNIX &reg; is a registered Trademark of The Open Group.<br>
Copyright &copy; 1997 The Open Group
<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]

</font></center><hr size=2 noshade>
</body></html>
